package com.hy.example.shared.utils;

import com.hy.mining.sa.model.UserDTO;
import lombok.extern.slf4j.Slf4j;

import java.util.Optional;

@Slf4j
public class UserCustomAuditorAware implements CustomAuditorAware {
    @Override
    public Optional<String> getCurrentAuditorName() {
        return UserAuditorHelper.getCurrentUser().map(UserDTO::getUserName);
    }

    @Override
    public Optional<String> getCurrentAuditorNickName() {
        return UserAuditorHelper.getCurrentUser().map(UserDTO::getNickName);
    }

    @Override
    public Optional<String> getToken() {
        return UserAuditorHelper.retrieveCurrentToken();
    }

    @Override
    public Optional<Long> getCurrentAuditor() {
        return UserAuditorHelper.getCurrentUser().map(UserDTO::getId);
    }


}
